package com.gc.cscott.cli;

import org.apache.commons.lang.StringUtils;

/**
 *
 * @author root
 */
public enum CommandsEnum {
    ListCompetitors(ListCompetitorsCommand.class, "--list-competitors"),
    Backup(BackupCommand.class, "--backup"),
    ValidateSolutions(ValidateSolutionsCommand.class, "--validate-solutions"),
    ListLanguages(ListLanguagesCommand.class, "--list-languages"),
    SeparateCompetitorsByLanguage(SeparateCompetitorsByLanguageCommand.class, "--separate-competitors-by-language"),
    CompileSources(CompileCommand.class, "--compile-code"),
    FindCheaters(FindCheatersCommand.class, "--find-cheaters"),
    PerformTests(PerformTestsCommand.class, "--perform-tests"),
    GroupZeroValueCompetitors(GroupZeroValueCompetitorsCommand.class, "--group-zero-value-competitors"),
    GroupCompetitorsWithoutCompiledSources(GroupCompetitorsWithoutCompiledSourcesCommand.class, "--group-competitors-without-compiled-sources"),
    ReportResults(ReportResultsCommand.class, "--report-results"),
    ReportPersonalResults(ReportPersonalResultsCommand.class, "--report-personal-results"),
    ReportPersonalResultsHtml(ReportPersonalResultsHtmlCommand.class,"--report-personal-results-html"),
    ReportPersonalResultsWiki(ReportPersonalResultsWikiCommand.class,"--report-personal-results-wiki"),
    ReVerifyTestReults(ReVerifyTestReultsCommand.class,"--re-verify-test-results"),
    ;
    String commandName;
    Class<? extends Command> commandType;

    private CommandsEnum(Class<? extends Command> commandType, String commandName) {
        this.commandType = commandType;
        this.commandName=commandName;
    }

    public Class<? extends Command> getCommandType() {
        return commandType;
    }

    public String getCommandName(){
        return commandName;
    }

    public String getCommandShortName(){
        StringBuilder shortName = new StringBuilder("-");
        for(String word:StringUtils.split(getCommandName(), "-")){
            shortName.append(StringUtils.substring(word, 0,1).toLowerCase());
        }
        return shortName.toString();
    }
}
